home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sun Solutions 1997 April to September
/
Sun Solutions CD - APR '97 - SEP '97 (704-3778-12 Rev. H)(Sun Microsystems, Inc.)(1997).iso
/
products
/
.wais
/
makedesc.bak
< prev
next >
Wrap
Text File
|
1995-08-22
|
14KB
|
628 lines
#!/net/pinatubo/opt/PUBperl5/bin/perl5
# /export/scratch/illustra/bin/perl5
# /opt/PUBperl5/bin/perl5
#
# makedesc.pl
#
# Generate The Wais Tree
#
# Copyright Creative Dynamics, Inc. 1995
#
#$dirn = $0;
#$dirn =~ s#(.*)/.*$#$1#;
#require "$dirn/common.pl";
$CATDB_NAME = "catalyst";
$USER = "miadmin";
#
# use the libmi stuff
#
use Mi;
$lastCategory = "";
$lastSubCategory = "";
$chapterCount = 0;
$fileOpen = 0;
### Set up output directory
$outputDirectory = "wais-src";
umask(022);
mkdir($outputDirectory, 0777); # make an output directory for book
chdir "$outputDirectory" || die "Can't cd to $outputDirectory\n";
unlink(<*.*>); # delete all existing files in the output directory
{
local($query,$num_col, @record);
local($db, $row_desc, $result, $row, $col, $row_num, $error);
### the query
$query = "
select p.Product_id, p.SolCompatible,
p.ProdCatName, p.ProdSubCat, p.ProdName, v.VendorName,
p.ProdShortDesc, p.ProdLongDesc,
p.ProdHomePage, p.ProdImage, p.SrcAvail, p.ProdSrcLang,
p.ProdSpecHand,
v.VendorAddr1, v.VendorAddr2, v.VendorAddr3, v.VendorCity,
v.VendorPostCode,
v.VendorState, v.VendorZip, v.VendorCountry,
v.VendorPhone1code, v.VendorPhone1,
v.VendorPhone2code, v.VendorPhone2,
v.VendorFaxCode, v.VendorFax,
v.VendorEmailCode, v.VendorEmail,
v.VendorURL
from Vendor v using(lock=table),
Assoc_ProdVend a using(lock=table),
Products p using(lock=table)
where a.ProdId = p.Product_id
and a.VendId = v.Vendor_id
and p.Product_id < 10
order by p.ProdCatName, p.ProdSubCat, p.ProdName
;";
# where p.Product_id < 50 -- use to limit
# alternate order: order by p.ProdCatName, p.ProdSubCat, p.ProdName, v.VendorName
### query the database
($db = Mi::open("$CATDB_NAME", "$USER", "") ) || die "Can't open Illustra database\n";
(Mi::exec($db, "$query", 0) == 0) || die "Can't exec Illustra query\n";
print " Query Sent\n";
(($result = Mi::get_result($db)) == 1) || die "Got bad result from Illustra\n";
print " Got Results\n";
($row_desc = Mi::get_row_desc_without_row($db)) || die "Error on row description \n";
$num_col = Mi::column_count($row_desc);
print " Results Have $num_col Columns\n";
$row_num = 0;
while ($row = Mi::next_row($db, \$error))
{
$row_num++;
print " Processing row $row_num...\n";
foreach $col (0..$num_col-1)
{
Mi::value($row, $col, $colval, $retlen);
$record[$col] = $colval;
}
### Fix the data
# map double occurrences of ' to single '
foreach $count (2..12)
{
$record[$count] =~ s/\'\'/\'/g;
}
### Trim trailing spaces
foreach $count (2..30)
{
$record[$count] =~ s/ *$//g;
}
### Now print out the data for this product
if ($lastCategory ne $record[2])
{
++$chapterCount; # increment chapter count
$outputChapterFile = "chap" . $chapterCount";
mkdir($outputChapterFile, 0777);
chdir "$outputChapterFile" || die "Can't cd to $outputChapterFile\n";
unlink(<*>);
$lastCategory = $record[2];
}
if ($lastSubCategory ne $record[3])
{
chdir "..";
mkdir($record[3], 077);
chdir "$record[3]" || die "Can't cd to $record[3]\n";
inlink(<*>);
}
&print_productheader($record[2]);
&print_specialpara("H3", &build_productindex($record[5]), $record[5]);
&print_specialpara("H4", &build_vendorindex($record[4] . ":" . $record[5]), $record[4]);
# 6 p.ProdShortDesc,
# 7 p.ProdLongDesc,
# choose the Long Description if it exists
$description = ($record[7] =~ /\S/) ? $record[7] : $record[6];
&print_multi("P", $description);
# 8 p.ProdHomePage,
if ($record[8] =~ /\S/)
{
&print_para("I", $record[8]);
}
# 9 p.ProdImage,
### NO PRODUCT IMAGE SUPPORT, YET
#&print_anchor(6);
### TEMP NEED TO FIX THIS
# &print_para("P", "Platforms supported: SPARC");
# 10 p.SrcAvail,
$answer = ($record[10] =~ /t/) ? "yes" : "no";
&print_para("P", "Source available: $answer");
# 11 p.ProdSrcLang,
&print_para("P", "Language: $record[11]");
# 12 p.ProdSpecHand,
#
# remove [ and ] brackets, also fix spaces and comma
#
$record[12] =~ s/^\[//g;
$record[12] =~ s/ *]$//g;
$record[12] =~ s/^ *,//g;
$record[12] =~ s/ +,/, /g;
if ($record[12] =~ /\S/)
{
&print_para("P", "Additional Requirements: $record[12]");
}
# 5 v.VendorName,
&print_para("I", $record[5]);
# 13 v.VendorAddr1,
# 14 v.VendorAddr2,
# 15 v.VendorAddr3,
foreach $count (13..15)
{
&print_para("I", $record[$count]) if ($record[$count] =~ /\S/);
}
# 16 v.VendorCity,
# 17 v.VendorPostCode,
# 18 v.VendorState,
# 19 v.VendorZip,
# 20 v.VendorCountry,
# $record[16] =~ s/ $//g;
$address = $record[16] . ",";
foreach $count (18..20)
{
$address .= " " . $record[$count] if ($record[$count] =~ /\S/);
}
&print_para("I", $address);
&print_para("I","Postal Code: $record[17]") if ($record[17] =~ /\S/);
# 21 v.VendorPhone1code,
# 22 v.VendorPhone1,
# 23 v.VendorPhone2code,
# 24 v.VendorPhone2,
# 25 v.VendorFaxCode,
# 26 v.VendorFax,
# 27 v.VendorEmailCode,
# 28 v.VendorEmail,
$text = "";
$text = $record[21] . " " if ($record[21] =~ /\S/);
&print_para("I","Phone1: $text$record[22]") if ($record[22] =~ /\S/);
$text = "";
$text = $record[23] . " " if ($record[23] =~ /\S/);
&print_para("I","Phone2: $text$record[24]") if ($record[24] =~ /\S/);
$text = "";
$text = $record[25] . " " if ($record[25] =~ /\S/);
&print_para("I","Fax: $text$record[26]") if ($record[26] =~ /\S/);
$text = "";
$text = $record[27] . " " if ($record[27] =~ /\S/);
&print_para("I","E-mail: $text$record[28]") if ($record[28] =~ /\S/);
# 29 v.VendorURL
&print_para("I",$record[29]) if ($record[29] =~ /\S/);
# 30 v.VendorLOGO
### NO VENDOR IMAGE SUPPORT, YET
#&print_anchor(6);
# End of Product
&print_para("HR", "");
}
Mi::close($db);
print "Processed $row_num records\n";
}
### TEMP TEST OF GRAPHIC
#&print_anchor(6);
# final stuff...
if ($fileOpen)
{
&print_chapterfooter();
close CHAPTER;
}
# process book file
&createbook();
print "Book Complete\n";
#------------------------------------------------------------------
# SUBROUTINES
#------------------------------------------------------------------
#------------------------------------------------------------------
# build_productindex
#
# subroutine build_productindex builds MIF for FrameMaker product index markers
sub build_productindex {
return &build_indexmarker(2, @_[0]);
}
#------------------------------------------------------------------
# build_vendorindex
#
# subroutine build_vendorindex builds MIF for FrameMaker vendor index markers
sub build_vendorindex {
return &build_indexmarker(2, @_[0]);
}
#------------------------------------------------------------------
# build_indexmarker
#
# subroutine build_indexmarker builds MIF for FrameMaker index markers
sub build_indexmarker {
local($markerType, $indexEntry) = @_;
return "<Marker <MType $markerType> <MText \`$indexEntry\'>>";
}
#------------------------------------------------------------------
# print_specialpara
#
# subroutine print_specialpara prints MIF for FrameMaker paragraph with a special character ie bullet
sub print_specialpara {
local($tag) = @_[0];
local($specialchar) = @_[1];
local($string) = @_[2];
print CHAPTER " <Para
<PgfTag \`$tag\'>
<ParaLine $specialchar
<String \`$string\'>
>
> # end of Para\n";
}
#------------------------------------------------------------------
# print_para
#
# subroutine print_para prints MIF for FrameMaker paragraph
sub print_para {
local($tag) = @_[0];
local($string) = @_[1];
print CHAPTER " <Para
<PgfTag \`$tag\'>
<ParaLine
<String \`$string\'>
>
> # end of Para\n";
}
#------------------------------------------------------------------
# print_uniquepara
#
# subroutine print_para prints MIF for FrameMaker paragraph
sub print_uniquepara {
local($device) = @_[0];
local($tag) = @_[1];
local($unique) = @_[2];
local($specialchar) = @_[3];
local($string) = @_[4];
print $device " <Para
<Unique $unique>
<PgfTag \`$tag\'>
<ParaLine $specialchar
<String \`$string\'>
>
> # end of Para\n";
}
#------------------------------------------------------------------
# print_multi
#
# subroutine print_multi prints MIF for multiple FrameMaker paragraph
sub print_multi {
local($tag) = @_[0];
local(@strings) = split(/\n/, @_[1]);
foreach $string (@strings)
{
if ($string =~ s/^--//)
{
&print_specialpara($tag, "<Char Bullet>", $string);
}
else
{
&print_para($tag, $string);
}
}
}
#------------------------------------------------------------------
# print_anchor
#
# subroutine print_anchor prints MIF for FrameMaker anchored frame
sub print_anchor {
local($id) = @_[0];
print CHAPTER " <Para
<ParaLine
<AFrame $id>
>
> # end of Para\n";
}
#------------------------------------------------------------------
# print_productheader
#
# subroutine print_chapterheader prints header for every chapter file
sub print_productheader {
local($category) = @_[0];
local($string) = @_[1];
print PRODUCT <<PRODUCTHEADER;
<html>
<head>
<title>Solaris - "$category"</title>
</head>
<body>
<A HREF="http://localhost:7999"><IMG SRC="../../../images/goto_toc.gif"> Catalyst Catalog Search Page</A> <A HREF="$string"><IMG SRC="../../../images/goto_back.gif"> Sub-category
<HR>
</A>
PRODUCTHEADER
}
#------------------------------------------------------------------
# print_chapterfooter
#
# subroutine print_chapterfooter prints footer for every chapter file
sub print_chapterfooter {
print CHAPTER <<CHAPTERFOOTER;
> # end of TextFlow
# End of Generated MIF File for the Sun Solutions Catalog
CHAPTERFOOTER
}
#------------------------------------------------------------------
# print_section
#
# subroutine print_section prints the section file for every chapter
sub print_section {
local($category) = @_;
local($outputSectionFile, $cnt, $word, @words);
$outputSectionFile = "sect" . $chapterCount . ".mif";
open(SECTION, ">$outputSectionFile") || do
{
die "Can't open SECTION file $outputSectionFile\n";
};
#----------------------
# HEADER
print SECTION <<SECTIONHEADER;
<MIFFile 4.00> # Developed by the Carl Group, Inc
# for the Sun Solutions Catalog
include(../secthead.mif)
SECTIONHEADER
@words = split(" ", $category); # place into array
@words = grep(!/^ $/, @words); # remove spaces
$cnt = @words; # count elements
if ($cnt == 1)
{
&print_uniquepara(SECTION, "Chap Title", 123, "", "");
&print_uniquepara(SECTION, "Chap Title", 124, "", "");
&print_uniquepara(SECTION, "Chap Title", 125, "<AFrame 1>", @words[0]);
}
elsif ($cnt == 2)
{
&print_uniquepara(SECTION, "Chap Title", 123, "", "");
&print_uniquepara(SECTION, "Chap Title", 124, "", @words[0]);
&print_uniquepara(SECTION, "Chap Title", 125, "<AFrame 1>", @words[1]);
}
elsif ($cnt == 3)
{
&print_uniquepara(SECTION, "Chap Title", 123, "", @words[0]);
&print_uniquepara(SECTION, "Chap Title", 124, "", @words[1]);
&print_uniquepara(SECTION, "Chap Title", 125, "<AFrame 1>", @words[2]);
}
print SECTION <<SECTIONBODY;
> # end of TextFlow
<TextFlow
<Para
<Unique 95>
<PgfTag `Chap Head'>
<ParaLine
<TextRectID 12>
>
> # end of Para
<Para
<Unique 100>
<PgfTag `Chap Head'>
<ParaLine
SECTIONBODY
print SECTION " <String `SECTION $chapterCount'> # Section with Number\n >\n > # end of Para\n";
#-------------------------
# FOOTER
print SECTION <<SECTIONFOOTER;
> # end of TextFlow
# End of MIFFile
SECTIONFOOTER
close SECTION;
}
#------------------------------------------------------------------
# createbook
#
# subroutine createbook creates the MIF version of a book
sub createbook {
local($bookFile, $chapter);
$bookFile = "ssc.mif";
open(BOOK, ">$bookFile") || do
{
die "Can't open CHAPTER file $bookFile\n";
};
&print_bookheader();
for(1..$chapterCount)
{
&print_bookcomponent($_);
}
&print_bookfooter();
}
#------------------------------------------------------------------
# print_bookheader
#
# subroutine print_bookheader prints MIF header for the book file
sub print_bookheader {
print BOOK <<BOOKHEADER
<Book 4.0> # Generated by The Carl Group, Inc
# for the Sun Solutions Catalog
<BookComponent
<FileName `<c\\>sscTOC.doc'>
<FileNameSuffix `TOC'>
<DeriveLinks No >
<DeriveType TOC >
<DeriveTag `H1'>
<DeriveTag `H2'>
<StartPageSide ReadFromFile >
<PageNumbering Continue >
<PgfNumbering Continue >
<PageNumPrefix `'>
<PageNumSuffix `'>
<DefaultPrint Yes >
<DefaultApply Yes >
<DefaultDerive Yes >
> # end of BookComponent
BOOKHEADER
}
#------------------------------------------------------------------
# print_bookcomponent
#
# subroutine print_bookcomponent prints MIF header for every component in the book file
sub print_bookcomponent {
local($component, $section, $chapter) = @_[0];
$section = "sect" . $component . ".doc";
$chapter = "chap" . $component . ".doc";
print BOOK <<BOOKCOMPONENT
<BookComponent
<FileName `<c\\>$section'>
<StartPageSide ReadFromFile >
<PageNumbering Continue >
<PgfNumbering Continue >
<PageNumPrefix `'>
<PageNumSuffix `'>
<DefaultPrint Yes >
<DefaultApply Yes >
> # end of BookComponent
<BookComponent
<FileName `<c\\>$chapter'>
<StartPageSide ReadFromFile >
<PageNumbering Continue >
<PgfNumbering Continue >
<PageNumPrefix `'>
<PageNumSuffix `'>
<DefaultPrint Yes >
<DefaultApply Yes >
> # end of BookComponent
BOOKCOMPONENT
}
#------------------------------------------------------------------
# print_bookfooter
#
# subroutine print_bookfooter prints MIF footer for the book file
sub print_bookfooter {
print BOOK <<BOOKFOOTER;
<BookComponent
<FileName `<c\\>sscIX.doc'>
<FileNameSuffix `IX'>
<DeriveLinks No >
<DeriveType IDX >
<DeriveTag `Index'>
<StartPageSide ReadFromFile >
<PageNumbering Continue >
<PgfNumbering Continue >
<PageNumPrefix `'>
<PageNumSuffix `'>
<DefaultPrint Yes >
<DefaultApply Yes >
<DefaultDerive Yes >
> # end of BookComponent
# end of Book
BOOKFOOTER
}